package com.example.binpacking.controller;

import com.example.binpacking.model.Result;
import com.example.binpacking.model.dto.PasswordRequest;
import com.example.binpacking.service.PasswordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;

@Slf4j
@RestController
@RequestMapping("/pelicanpsyc")
public class PasswordController {
    @Autowired
    private PasswordService passwordService;

    @PostMapping("/api/editkey")
    public Result editPassword(@RequestBody PasswordRequest request) {
        boolean success = passwordService.updatePassword(request);
        if (success) {
            return Result.success(200, "y", Collections.emptyList());
        } else {
            return Result.fail(200, "n", Collections.emptyList());
        }
    }
}
